Hans wrote:
Is it possible to put a unicode string on a querystring? How do I
escape/unescape this? I read values from a dropown list which may have any
UTF-8 character (chinese, greek or whatever).
If it is not possible I guess I have to post in the value instead but I
would like to keep the code as it is and only change the escape functions
which only works for ISO Latin characterset as far as I know.
With Netscape 6/7, Mozilla, IE5.5/6 and with Opera 7 there is
encodeURIComponent(string)
which is capable of processing Unicode strings, for instance
var string = '€';
encodeURIComponent(string)
yields
%E2%82%AC
which is an escaped UTF-8 encoding. It is then up to you to handle that
properly on the server, if you have ASP on the server make sure you
install JScript 5.5 or 5.6 there and you can simply use
decodeURIComponent
In some browsers escape is also Unicode capable however it yields a
different result e.g.
var string = '€';
escape(string)
yields
%u20AC
which is % as the escape character, u for unicode and then the hex code
of the Unicode code value.
--
Martin Honnen
http://JavaScript.FAQTs.com/